package com.paf.android.display;

import android.content.Context;
import android.graphics.Color;
import android.text.InputType;
import android.text.Spanned;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Console extends TextView {
	public Console(Context context, LinearLayout _parent) {
		super(context);
		
		this.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 240));
		//this.setText(R.string.consoleView);
		this.setBackgroundColor(Color.WHITE);
		this.setInputType(this.getInputType()|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
		this.setTextIsSelectable(true);
		this.setMaxLines(10);
    	_parent.addView(this);
	}
	
	//Public methods
	//Log : allows user to display a message in the console by having a trace() call in his code 
	public void log(String _message){
		Spanned spanned = android.text.Html.fromHtml("<font color='#FFFFFF'>"+_message+"</font>");
		this.append(spanned);
	}
	
	//Error : used to display system errors
	public void error(String _message){
		Spanned spanned = android.text.Html.fromHtml("<font color='#FF0000'>"+_message+"</font>");
		this.append(spanned);
	}
	
	//System : used to display system messages
	public void system(String _message){
		Spanned spanned = android.text.Html.fromHtml("<font color='#0000FF'>"+_message+"</font>");
		this.append(spanned);
	}
}
